package com.caozhi.mspeoject.nb_insurance.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.caozhi.mspeoject.nb_insurance.bean.Insurance;
import com.caozhi.mspeoject.nb_insurance.mapper.InsuranceMapper;
import com.caozhi.mspeoject.nb_insurance.remote.DistributedId;
import com.caozhi.mspeoject.nb_insurance.service.InsuranceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;
@Service
public class InsuranceServiceImpl extends ServiceImpl<InsuranceMapper, Insurance> implements InsuranceService{
  @Autowired
  private InsuranceMapper insuranceMapper;
  @Autowired
  private DistributedId distributedId;

    @Override
    public void addInsurance(Insurance insurance) {
        insurance.setId(distributedId.getDistributeID());
        insuranceMapper.insert(insurance);
    }

    @Override
    public void updateInsurance(Insurance insurance) {

    }

    @Override
    public void deleteInsurance(Insurance insurance) {

    }

    @Override
    public List<Insurance> getInsurance() {

        return insuranceMapper.selectList(null);
    }

  @Override
  public BigDecimal getInsurancePrice(Long id) {
    return insuranceMapper.selectById(id).getPrice();
  }

  @Override
  public Insurance getInsuranceById(Long id) {
    return insuranceMapper.selectById(id);
  }
}
